package listener;

import context.ComServerContext;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import message.StringMessage;

import java.util.Scanner;

/**
 * @author wb_zhulinzhong
 * @date 2021-04-14 19:18:27
 */
public class LoopServerSendMessageListener implements ChannelFutureListener {

    @Override
    public void operationComplete(ChannelFuture future) throws Exception {
        System.out.println("server启动成功");
        new Thread(() -> {
            Scanner scanner = new Scanner(System.in);
            while (true){
                System.out.print("输入客户端id：");
                String id = scanner.nextLine();
                System.out.print("输入信息：");
                String str = scanner.nextLine();
                StringMessage stringMessage = new StringMessage("server", str);
                ComServerContext.comContext().serverSendMessageToClientByClientId(stringMessage, id);
            }
        }).start();
    }
}
